<?php

// $Id:

/**
 *  @file Define 'Site visitor registration' form and handle its submission
 */

define('CINNAMON_MUSIC_GENRE_VID', '1');

/**
 * Site visitor registration form definition.
 * @param array $form_state Return form current selected values.
 */
function cinnamon_site_visitor_registration_form($form_state) {

  $form['user_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Seu nome'),
    '#default_value' => $form_state['user_name'],
    '#required' => TRUE,
  );

  $form['user_picture'] = array(
    '#type' => 'file',
    '#title' => t('Sua foto'),
  );

  $form['user_current_city'] = array(
    '#type' => 'textfield',
    '#title' => t('Sua cidade atual'),
    '#description' => t('Usado para indicar eventos próximos a você!'),
    '#default_value' => $form_state['user_current_city'],
    '#required' => TRUE,
  );

  //Load all music genre previously created to be selected by user while registering.
  $music_genres = taxonomy_get_tree(CINNAMON_MUSIC_GENRE_VID);
  $music_genres_options = array();
  foreach ($music_genres as $music_genre) {
    $music_genres_options[$music_genre->tid] = $music_genre->name;
  }
  
  $form['user_music_genre'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Preferência musical'),
    '#description' => t('Traz resultados mais adequados ao seu perfil!'),
    '#options' => $music_genres_options,
  );


  //$form['theme'] = 'cinnamon_site_visitor_registration_form';

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Finalizar'),
  );

  return $form;
}

/**
 *
 * @param array $form Registration form definitions.
 * @param array $form_state Current state of registration form after user submission.
 */
function cinnamon_site_visitor_registration_form_submit($form, &$form_state) {
  print_r($form_state);
  exit();
}